<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>城市级联</title>
</head>
<body>
	<select id="sid" onchange="demo(this.value)" >
		<option value="">--请选择--</option>
		<option value="0">安徽</option>
		<option value="1">江苏</option>
		<option value="2">广东</option>
	</select>
	<select id="cid">
		<option value="">--请选择--</option>
	</select>
</body>
	<script>

		sid = document.getElementById("sid");
		cid = document.getElementById("cid");
		var arr = new Array(3);
		arr[0] = ['合肥','芜湖','黄山'];
		arr[1] = ['南京','淮安','苏州'];
		arr[2] = ['广州','广州2','广州3'];

		function demo(obj){
			//固定长度
			cid.length=1;
			for(var i=0;i<arr[obj].length;i++){
				ob = new Option(arr[obj][i],i);
				cid.add(ob);
			}
		}


	</script>
</html>